export class PwdData {
    /**连接状态 */
    mStatus = EPwdStatus.CHECK_FAIL;//EPwdStatus
    pwd = "0000";//String
    /**设备编号 */
    deviceNumber = 0;//int
    /**设备版本 */
    deviceVersion = "";//String
    /**设备测试版本 */
    deviceTestVersion = "";
    /**是否饮酒 */
    isHaveDrinkData = false;
    /**抬头亮表 */
    isOpenNightTurnWriste = EFunctionStatus.UNKONW;
    /**防丢失 */
    findPhoneFunction = EFunctionStatus.UNKONW;
    /**穿戴检测 */
    wearDetectFunction = EFunctionStatus.UNKONW;

    toString() {
        return "PwdData{mStatus=" + this.matchStatus(this.mStatus) +
            ", 设备编号=" + this.deviceNumber + ", 设备版本='" + this.deviceVersion + '\'' + ", 设备测试版本='" + this.deviceTestVersion + '\'' + ", 是否有饮酒数据=" + this.isHaveDrinkData +
            ", 抬手亮屏=" + this.matchEFunctionStatus(this.isOpenNightTurnWriste) +
            ", 设置防丢=" + this.matchEFunctionStatus(this.findPhoneFunction) +
            ",佩戴检测=" + this.matchEFunctionStatus(this.wearDetectFunction) + '}';
    }

    setisOpenNightTurnWriste(_intV) {
        if (_intV == 0) {
            this.isOpenNightTurnWriste = EFunctionStatus.SUPPORT_CLOSE;
        } else if (_intV == 1) {
            this.isOpenNightTurnWriste = EFunctionStatus.SUPPORT_OPEN;
        } else if (_intV == 2) {
            this.isOpenNightTurnWriste = EFunctionStatus.UNSUPPORT;
        }
    }

    setfindPhoneFunction(_intV) {
        if (_intV == 1) {
            this.findPhoneFunction = EFunctionStatus.SUPPORT_OPEN;
        } else if (_intV == 2) {
            this.findPhoneFunction = EFunctionStatus.SUPPORT_CLOSE;
        }
        else {
            this.findPhoneFunction = EFunctionStatus.UNSUPPORT;
        }
    }

    setwearDetectFunction(_intV) {
        if (_intV == 1) {
            this.wearDetectFunction = EFunctionStatus.SUPPORT_OPEN;
        } else if (_intV == 2) {
            this.wearDetectFunction = EFunctionStatus.SUPPORT_CLOSE;
        }
        else {
            this.wearDetectFunction = EFunctionStatus.UNSUPPORT;
        }
    }

    matchStatus(value) {
        for (const key in EPwdStatus) {
            if (EPwdStatus[key] === value) {
                return key;
            }
        }
        return null;
    }

    matchEFunctionStatus(value) {
        for (const key in EFunctionStatus) {
            if (EFunctionStatus[key] === value) {
                return key;
            }
        }
        return null;
    }
}

export const EPwdStatus = {
    CHECK_FAIL: 0,
    CHECK_SUCCESS: 1,
    SETTING_FAIL: 2,
    SETTING_SUCCESS: 3,
    READ_FAIL: 4,
    READ_SUCCESS: 5,
    CHECK_AND_TIME_SUCCESS: 6,
    UNKNOW: 7
}


/**
 * 功能支持
 */
export const EFunctionStatus = {
    UNKONW: "UNKONW",
    SUPPORT_CLOSE: "SUPPORT_CLOSE",
    SUPPORT_OPEN: "SUPPORT_OPEN",
    UNSUPPORT: "UNSUPPORT",
    SUPPORT: "SUPPORT",

}